#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    ui->horizontalSlider->setMinimum(100); // 最大值
    ui->horizontalSlider->setMaximum(1920); // 最小值
    ui->horizontalSlider->setValue(800); // 初始值
    ui->horizontalSlider->setSingleStep(50); // 单步移动的数值

    ui->verticalSlider->setMinimum(100);
    ui->verticalSlider->setMaximum(1080);
    ui->verticalSlider->setValue(600);
    ui->verticalSlider->setSingleStep(50);
}

Widget::~Widget()
{
    delete ui;
}

// 通过滑动条控制窗口大小
void Widget::on_horizontalSlider_valueChanged(int value)
{
    ui->label_level->setText("value: " + QString::number(value));
    const QRect& rect = this->geometry();
    this->setGeometry(rect.x(), rect.y(), value, rect.height());
}

void Widget::on_verticalSlider_valueChanged(int value)
{
    ui->label_vertical->setText("value: " + QString::number(value));
    const QRect& rect = this->geometry();
    this->setGeometry(rect.x(), rect.y(), rect.width(), value);
}
